﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace SP_XHWeb.WebParts.Phone_GetNewsList
{
    [ToolboxItemAttribute(false)]
    public class Phone_GetNewsList : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/SP_XHWeb.WebParts/Phone_GetNewsList/Phone_GetNewsListUserControl.ascx";

        [WebBrowsable(true)]
        [WebDescription("列表URL")]
        [WebDisplayName("列表URL")]
        [DefaultValue("")]
        [Category("自定义属性")]
        [Personalizable(PersonalizationScope.Shared)]
        public string ListUrl
        {
            get;
            set;
        }

        [WebBrowsable(true)]
        [WebDescription("列表名称")]
        [WebDisplayName("列表名称")]
        [DefaultValue("")]
        [Category("自定义属性")]
        [Personalizable(PersonalizationScope.Shared)]
        public string ListName
        {
            get;
            set;
        }

        [WebBrowsable(true)]
        [WebDescription("限制显示条数")]
        [WebDisplayName("限制显示条数")]
        [DefaultValue("")]
        [Category("自定义属性")]
        [Personalizable(PersonalizationScope.Shared)]
        public string ListNum
        {
            get;
            set;
        }

        
        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);

            //自定义属性
            Phone_GetNewsListUserControl puc = control as Phone_GetNewsListUserControl;
            puc.ListURL = this.ListUrl;
            puc.ListName = this.ListName;
            puc.ListNum = this.ListNum;
            //

            Controls.Add(control);
        }
    }
}
